package com.model.defaults.tabsheet;

import java.util.Map;

import org.hibernate.Session;

import com.core.GlobalConstants;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.TabSheetItem;
import com.model.UserContextName;


public class ModelDefaultTabsheetProject {

	public static void createTabsheetItemsProjectBrowse ( Session session,
	                                                      Map <String, UserContextName> userContexts ) {

		TabSheetItem pojo = null;
		UserContextName contextName_1 = null;

		ActionScript actionScript = null;
		KeyValue actionScriptParam = null;


		actionScript = new ActionScript();
		actionScript.setActionScriptText("BrowseProjects?{selectedTab}");
		actionScript.setActionScriptType("servlet");

		actionScriptParam = new KeyValue("selectedTab", "selectedTab=1");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_DASHBOARD);
		pojo = new TabSheetItem();
		pojo.setName("BrowseProjects.Projectslist");
		pojo.setCaption("Projects list");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setJspNameInContext("details/tabProjectsList.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTLIST);
		pojo.setIsDefault(true);
		pojo.setActionScript(actionScript);
		session.save(pojo);

		/**
         * 
         */

		actionScript = new ActionScript();
		actionScript.setActionScriptText("BrowseProjects?{selectedTab}");
		actionScript.setActionScriptType("servlet");

		actionScriptParam = new KeyValue("selectedTab", "selectedTab=2");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTSLIST);
		pojo = new TabSheetItem();
		pojo.setCaption("Filters");
		pojo.setName("BrowseProjects.Filters");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setJspNameInContext("details/tabProjectFiltersList.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTLIST);
		pojo.setActionScript(actionScript);
		session.save(pojo);
	}



	public static void createTabsheetItemsProjectOpen ( Session session,
	                                                    Map <String, UserContextName> userContexts ) {

		/*
		 * OpenProject
		 */

		TabSheetItem pojo = null;
		UserContextName contextName_1 = null;

		ActionScript actionScript = null;
		KeyValue actionScriptParam = null;


		actionScript = new ActionScript();

		actionScriptParam = new KeyValue("p2", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("t1", "selectedTab=1");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("ProjectInfo?{p2}&{t1}");
		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTINFO);
		pojo = new TabSheetItem();
		pojo.setName("BrowseProjects.Description");
		pojo.setCaption("Description");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setJspNameInContext("details/tabProjectInfo.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTINFO);
		pojo.setIsDefault(true);
		pojo.setActionScript(actionScript);
		session.save(pojo);

		/**
		 * Issues
		 */

		actionScript = new ActionScript();

		actionScriptParam = new KeyValue("p2", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("t1", "selectedTab=2");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("ProjectInfo?{p2}&{t1}");
		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTINFO);
		pojo = new TabSheetItem();
		pojo.setName("BrowseProjects.Issues");
		pojo.setCaption("Issues");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setJspNameInContext("details/tabProjectTasksList.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTINFO);
		pojo.setActionScript(actionScript);
		session.save(pojo);

		/**
		 * Versions
		 */

		actionScript = new ActionScript();

		actionScriptParam = new KeyValue("p2", "?");
		actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScriptParam = new KeyValue("t1", "selectedTab=3");
		session.save(actionScriptParam);
		actionScript.getParams().add(actionScriptParam);

		actionScript.setActionScriptType("servlet");
		actionScript.setActionScriptText("ProjectInfo?{p2}&{t1}");
		session.save(actionScript);

		contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_PROJECTINFO);
		pojo = new TabSheetItem();
		pojo.setName("BrowseProjects.Versions");
		pojo.setCaption("Versions");
		pojo.getUserContextNameVisibleIn().add(contextName_1);
		pojo.setJspNameInContext("details/tabProjectVersionsList.jsp");
		pojo.setServletNameToExecute(GlobalConstants.SERVLET_PROJECTINFO);
		pojo.setActionScript(actionScript);
		session.save(pojo);
	}



}
